package com.only4play.practice.customerapi.controller;

import com.google.common.collect.Lists;
import com.only4play.codegen.support.model.JsonObject;
import com.only4play.practice.common.enums.AccountType;
import com.only4play.practice.common.enums.OrderType;
import com.only4play.practice.common.other.CodeValue;
import com.only4play.practice.ordercenter.api.model.domainmodel.OrderCreateModel;
import com.only4play.practice.ordercenter.api.model.domainmodel.OrderItemModel;
import com.only4play.practice.ordercenter.api.feign.OrderBaseFeignService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;

/**
 * @author mdy
 * * @date 2024/9/14
 */
@RestController
@RequestMapping("/custom/api/v1/test")
public class MainTestController {

    @Resource
    private OrderBaseFeignService orderBaseFeignService;

    /**
     * 生成订单
     */
    @RequestMapping("/make/order")
    public void test(){
        OrderCreateModel model = new OrderCreateModel();
        model.setAccountId(2L);
        model.setOrderType(OrderType.SHOP);
        model.setAccountType(AccountType.CORP);
        model.setOperateUser("管理员");
        model.setPayList(Collections.EMPTY_LIST);
        List<CodeValue> attrs = Lists.newArrayList();
        CodeValue kv = new CodeValue();
        kv.setK("channel");
        kv.setV("ios");
        kv.setL("渠道");
        attrs.add(kv);

        CodeValue kv1 = new CodeValue();
        kv1.setK("city");
        kv1.setV("河北");
        kv1.setL("城市");
        attrs.add(kv1);

        CodeValue kv2 = new CodeValue();
        kv2.setK("shop");
        kv2.setV("二号店");
        kv2.setL("二号店");
        attrs.add(kv2);
        model.setAttrs(attrs);

        List<OrderItemModel> itemModels = Lists.newArrayList();
        OrderItemModel orderItemModel = new OrderItemModel();
        orderItemModel.setSkuId("1");
        orderItemModel.setItemCount(1);
        orderItemModel.setFeeRemark("衣服一件");
        orderItemModel.setGoodsName("衣服");
        orderItemModel.setRealAmount(10320L);
        OrderItemModel orderItemModel2 = new OrderItemModel();
        orderItemModel2.setSkuId("2");
        orderItemModel2.setItemCount(1);
        orderItemModel2.setFeeRemark("鞋子");
        orderItemModel2.setGoodsName("鞋子");
        orderItemModel2.setRealAmount(10640L);
        itemModels.add(orderItemModel);
        itemModels.add(orderItemModel2);
        model.setItemInfoList(itemModels);

        JsonObject<Boolean> jsonResult = orderBaseFeignService.createOrder(model);
        System.out.println(jsonResult);
    }



}
